﻿using OpenCvSharp;

using System.Collections.ObjectModel;
using System.Linq;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    [Filter("通道分离", FilterType.Algorithm)]
    public class AlgorithmSplit : FilterBase
    {
        private Mat[] spitMats = new Mat[] { };

        /// <summary>
        /// 通道数据
        /// </summary>
        [OutputParameter("通道数据")]
        public Mat[] SpitMats
        {
            get => spitMats; set
            {
                spitMats = value;
                RaisedPropertyChanged();
            }
        }
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            SpitMats = Cv2.Split(mat);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, SpitMats?.FirstOrDefault());
        }
    }
}
